package utils;

import entity.Score;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class GetScore {
    static JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUtil.getDataSource());
    static ArrayList<Score> scores = new ArrayList<Score>();

    public static ArrayList<Score> get() {
        String sql = "select * from score order by Score desc limit 10";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map :
                list) {
            Score score = new Score();
            score.setScore((Integer) map.get("Score"));
            score.setAll_jump((Integer) map.get("All_jump"));
            score.setJump_catus((Integer) map.get("jump_catus"));
            score.setAvoid((Integer) map.get("avoid_pterosaur"));
            scores.add(score);
        }
        return scores;
    }

}
